package cn.koala.key.api;

import cn.koala.key.common.feign.BaseApi;
import cn.koala.key.entity.*;
import cn.koala.key.receipt.dto.*;
import cn.koala.key.receipt.vo.*;
import cn.koala.key.scraped.domain.dto.ScrapedOrderDTO;
import cn.koala.key.scraped.domain.dto.ScrapedSerachDTO;
import cn.koala.key.scraped.domain.vo.ScrapedOrderDetailVO;
import cn.koala.key.scraped.domain.vo.ScrapedOrderVO;
import cn.koala.key.stock.domain.dto.*;
import cn.koala.key.stock.domain.vo.EnterStockDetailVO;
import cn.koala.key.stock.domain.vo.KeyInfoVO;
import cn.koala.key.stock.domain.vo.LeaveStockDetailVO;
import cn.koala.key.stock.domain.vo.PrintBarCodeVO;
import cn.seed.common.core.Result;
import cn.seed.common.core.ResultList;
import feign.Param;
import feign.RequestLine;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


/**
 * 
 * @Description: 钥匙管理底层接口
 * @exception:
 * @author: 32415
 */
public interface KeyManagementApi extends BaseApi {

    /**
     * 入库查询
     * @description list
     * @param enterStockSearch
     * @return cn.seed.common.core.Result<cn.seed.common.core.ResultList<cn.koala.key.entity.EnterStock>>
     * @Exception
     * @author shuai.xu
     * @time 2019/4/29 14:15
    */
    @RequestLine("GET /enter-stock")
    Result<ResultList<EnterStock>> list(StockSearch enterStockSearch);

    /**
     * 新增/编辑入库单
     * @description insertEnterStock
     * @param enterStockDTO
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/4/29 14:44
    */
    @RequestLine("POST /enter-stock")
    Result insertOrUpdateEnterStock(EnterStockDTO enterStockDTO);

    /**
     * 作废/提交入库单
     * @description invalid
     * @param orderNo 入库单号
     * @param status 入库单状态
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/4/30 11:14
    */
    @RequestLine("PUT /enter-stock?orderNo={orderNo}&status={status}")
    Result invalidOrSubmit(@Param("orderNo") String orderNo,@Param("status") Integer status);

    /**
     * 更新入库钥匙状态
     * @description updateDetail
     * @param orderNo
     * @param isDeleted
     * @param isStorage
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/4/30 15:13
    */
    @RequestLine("PUT /enter-stock/detail?orderNo={orderNo}&isDeleted={isDeleted}&isStorage={isStorage}")
    Result updateDetail(@Param("orderNo") String orderNo,@Param("isDeleted") Integer isDeleted,@Param("isStorage") Integer isStorage);

    /**
     * 入库详情
     * @description selectDetail
     * @param orderNo
     * @return cn.seed.common.core.Result<cn.koala.key.stock.domain.vo.EnterStockDetailVO>
     * @Exception      
     * @author shuai.xu
     * @time 2019/5/5 9:07
    */
    @RequestLine("GET /enter-stock/detail?orderNo={orderNo}")
    Result<EnterStockDetailVO> selectDetail(@Param("orderNo") String orderNo);

    /**
     * 扫码获取钥匙信息
     * @description scanCode
     * @param keyBarCode
     * @param status(1:借出,2:在库)
     * @return cn.seed.common.core.Result<cn.koala.key.stock.domain.vo.KeyInfoVO>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/5 9:07
    */
    @RequestLine("POST /key-info/scanCode?status={status}")
    Result<List<KeyInfoVO>> scanCode(List<String> keyBarCode,@Param("status")Integer status);

    /**
     * 出库查询
     * @description leaveStockList
     * @param leaveStockSearch
     * @return cn.seed.common.core.Result<cn.seed.common.core.ResultList<cn.koala.key.entity.LeaveStock>>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/5 9:59
    */
    @RequestLine("GET /leave-stock")
    Result<ResultList<LeaveStock>> leaveStockList(StockSearch leaveStockSearch);

    /**
     * 新增/编辑出库单
     * @description insertOrUpdateLeaveStock
     * @param leaveStockDTO
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/5/5 11:27
    */
    @RequestLine("POST /leave-stock")
    Result insertOrUpdateLeaveStock(LeaveStockDTO leaveStockDTO);

    /**
     * 出库/作废出库单
     * @description invalid
     * @param orderNo 出库单号
     * @param status 出库单状态
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/4/30 11:14
     */
    @RequestLine("PUT /leave-stock?orderNo={orderNo}&status={status}")
    Result invalidOrOutStock(@Param("orderNo") String orderNo,@Param("status") Integer status);

    /**
     * 更新出库钥匙状态
     * @description updateOutStockDetail
     * @param orderNo
     * @param isDeleted
     * @param isStorage
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/5/5 11:31
    */
    @RequestLine("PUT /leave-stock/detail?orderNo={orderNo}&isDeleted={isDeleted}&isStorage={isStorage}")
    Result updateOutStockDetail(@Param("orderNo") String orderNo,@Param("isDeleted") Integer isDeleted,@Param("isStorage") Integer isStorage);

    /**
     * 出库详情(编辑)
     * @description selectOutStockDetail
     * @param orderNo
     * @return cn.seed.common.core.Result<cn.koala.key.stock.domain.vo.LeaveStockDetailVO>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/5 12:02
    */
    @RequestLine("GET /leave-stock/detail?orderNo={orderNo}")
    Result<LeaveStockDetailVO> selectOutStockDetail(@Param("orderNo") String orderNo);

    /**
     * 挂失
     * @description reportLoss
     * @param keyBarCode
     * @param dropReason
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/5/6 15:24
    */
    @RequestLine("PUT /key-info/report-loss?keyBarCode={keyBarCode}&dropReason={dropReason}")
    Result reportLoss(@Param("keyBarCode")String keyBarCode,@Param("dropReason") String dropReason);

    /**
     * 入库
     * @description inStock
     * @param keyBarCode
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/5/6 15:24
    */
    @RequestLine("PUT /key-info/in-stock?keyBarCode={keyBarCode}")
    Result inStock(@Param("keyBarCode")String keyBarCode);

    /**
     * 库存查询
     * @description selectInventory
     * @param inventorySearch
     * @return cn.seed.common.core.Result<cn.seed.common.core.ResultList<cn.koala.key.stock.domain.vo.KeyInfoVO>>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/6 17:19
    */
    @RequestLine("GET /key-inventory")
    Result<ResultList<KeyInfoVO>> selectInventory(InventorySearch inventorySearch);

    /**
     * 库存导出
     * @description exportInventory
     * @param inventorySearch
     * @return cn.seed.common.core.Result<cn.seed.common.core.ResultList<cn.koala.key.stock.domain.vo.KeyInfoVO>>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/7 16:30
    */
    @RequestLine("GET /key-inventory/print")
    Result<List<KeyInfoVO>> exportInventory(InventorySearch inventorySearch);

    /**
     * @Description: 借用单查询
     *
     * @param borrowOrderSearch
     * @return ResultList<BorrowOrder>
     * @author: 32415
     * @time: 2019/5/8 9:27
     */
    @RequestLine("POST /borrow-orders/search")
    Result<ResultList<BorrowOrder>> searchBorrowOrder(BorrowOrderSearchDTO borrowOrderSearch);

    @RequestLine("PUT /borrow-orders/submit?id={id}")
    Result submit(@Param("id") Long id);

    @RequestLine("PUT /borrow-orders/invalid?id={id}")
    Result invalid(@Param("id") Long id);

    @RequestLine("PUT /borrow-orders/check")
    Result check(List<BorrowOrderCheckDTO> borrowOrderCheckList);

    @RequestLine("GET /borrow-orders/{id}")
    Result<BorrowOrder> getById(@Param("id") Long id);

    @RequestLine("POST /borrow-orders")
    Result createOrEdit(BorrowOrderDTO borrowOrderDTO);

    @RequestLine("GET /borrow-order-addressees/{orderNo}")
    Result<BorrowOrderAddressee> selectByOrderNo(@Param("orderNo") String orderNo);

    @RequestLine("PUT /borrow-order-addressees")
    Result editBorrowOrderAddressee(BorrowOrderAddressee borrowOrderAddressee);

    @RequestLine("GET /borrow-order-details/{orderNo}")
    Result<List<KeyInfo>> selectKeyInfosByOrderNo(@Param("orderNo") String orderNo);

    @RequestLine("POST /borrow-order-details/out")
    Result lend(BorrowOrderDetailDTO borrowOrderDetailDTO);

    @RequestLine("GET /borrow-order-returns/{orderNo}")
    Result<BorrowOrderReturn> selectBorrowOrderReturnByOrderNo(@Param("orderNo") String orderNo);

    @RequestLine("POST /borrow-order-returns")
    Result createBorrowOrderReturn(BorrowOrderReturn borrowOrderReturn);

    @RequestLine("POST /borrow-order-returns/confirm")
    Result confirmReturn(BorrowOrderReturnDTO borrowOrderReturnDTO);

    @RequestLine("GET /key-infos/car-vin-no?carVin={carVin}&carNo={carNo}&num={num}")
    Result<List<KeyInfoVO>> getByCarNoAndCarVin(@Param("carVin") String carVin, @Param("carNo") String carNo, @Param("num") int num);

    @RequestLine("GET /cities?source={source}")
    Result<List<CityVO>> getAllCities(@Param("source") int source);

    @RequestLine("GET /stores?source={source}&cityId={cityId}")
    Result<List<StoreVO>> getAllShops(@Param("source") int source,
                                      @Param("cityId") Integer cityId);

    @RequestLine("GET /stores/{id}")
    Result<CarRepairShop> getShopById(@Param("id") Integer id);

    @RequestLine("GET /key-infos/car-vin-no/info?carVin={carVin}&carNo={carNo}&num={num}")
    Result<List<KeyInfoVO>> getByCarNoAndCarVin(@Param("carVin") String carVin, @Param("carNo") String carNo);

    @RequestLine("GET /cars?carVin={carVin}&carNo={carNo}&order={order}")
    Result<List<CarInfoVO>> getCars(@Param("carNo") String carNo, @Param("carVin") String carVin, @Param("order") Integer order);

    @RequestLine("POST /cars/car-types")
    Result<List<CarType>> getCarsbyCarTypes(List<Integer> carTypes);

    /**
     * 打印条码
     * @description printBarCode
     * @param keyBarCode
     * @return cn.seed.common.core.Result<cn.koala.key.stock.domain.vo.PrintBarCodeVO>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/16 10:00
    */
    @RequestLine("GET /key-inventory/printBarCode?keyBarCode={keyBarCode}")
    Result<PrintBarCodeVO> printBarCode(@Param("keyBarCode")String keyBarCode);

    @RequestLine("GET /cars/car-type?carType={carType}")
    Result<List<CarType>> getCarsbyCarTypes(@Param("carType")Integer carType);

    /**
     * 批量导入新车
     * @description importNewCar
     * @param newCarDTOList
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/5/20 14:32
    */
    @RequestLine("POST /new-car/file")
    Result importNewCar(List<NewCarDTO> newCarDTOList);

    /**
     * 批量打印条码
     * @description batchPrintBarCode
     * @param startCode
     * @param endCode
     * @return java.util.List<cn.koala.key.stock.domain.vo.PrintBarCodeVO>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/27 9:37
    */
    @RequestLine("GET /key-inventory/batchPrintBarCode?startCode={carType}&endCode={endCode}")
    Result<List<PrintBarCodeVO>> batchPrintBarCode(@Param("startCode")Integer startCode, @Param("endCode")Integer endCode);

    /**
     * 根据车架集合查询钥匙信息
     * @description batchSelectKeyByCarVinList
     * @param carVin
     * @return cn.seed.common.core.Result<java.util.List<cn.koala.key.stock.domain.vo.KeyInfoVO>>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/27 18:57
    */
    @RequestLine("POST /key-info/car-vin/info/list")
    Result<List<KeyInfoVO>> batchSelectKeyByCarVinList(List<CarVinDTO> carVin);

    /**
     * 分页查询报废单
     * @description scrapedList
     * @param scrapedSerachDTO
     * @return cn.seed.common.core.Result<cn.seed.common.core.ResultList<cn.koala.key.scraped.domain.vo.ScrapedOrderVO>>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/30 10:17
    */
    @RequestLine("GET /scraped/orders")
    Result<ResultList<ScrapedOrderVO>> scrapedList(ScrapedSerachDTO scrapedSerachDTO);

    /**
     * 扫码获取钥匙信息(报废使用)
     * @description scrapedScanCode
     * @param keyBarCode
     * @return cn.seed.common.core.Result<java.util.List<cn.koala.key.stock.domain.vo.KeyInfoVO>>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/30 10:44
    */
    @RequestLine("POST /key-info/scraped/scanCode")
    Result<List<KeyInfoVO>> scrapedScanCode(List<String> keyBarCode);

    /**
     * 获取报废单详情
     * @description getScrapedDetailByOrderNo
     * @param orderNo
     * @return cn.seed.common.core.Result<cn.koala.key.scraped.domain.vo.ScrapedOrderDetailVO>
     * @Exception
     * @author shuai.xu
     * @time 2019/5/30 16:41
    */
    @RequestLine("GET /scraped/orders/detail")
    Result<ScrapedOrderDetailVO> getScrapedDetailByOrderNo(@Param("orderNo")String orderNo);

    /**
     * 新增编辑报废单
     * @description insertOrUpdateScrapedOrder
     * @param scrapedOrderDTO
     * @return void
     * @Exception      
     * @author shuai.xu
     * @time 2019/5/31 13:49
    */
    @RequestLine("POST /scraped/orders")
    Result insertOrUpdateScrapedOrder(ScrapedOrderDTO scrapedOrderDTO);

    /**
     * 提交/作废报废单
     * @description invalidOrSubmitScraped
     * @param orderNo
     * @param status
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/5/31 17:10
    */
    @RequestLine("PUT /scraped/orders?orderNo={orderNo}&status={status}")
    Result invalidOrSubmitScraped(@Param("orderNo")String orderNo, @Param("status")Integer status);

    /**
     * 新车提交
     * @description newCarSubmit
     * @param orderNo
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/6/3 10:51
    */
    @RequestLine("PUT /new-car/submit?orderNo={orderNo}")
    Result newCarSubmit(@Param("orderNo")String orderNo);

    /**
     * 新车作废
     * @description newCarInvalid
     * @param orderNo
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/6/3 10:51
    */
    @RequestLine("PUT /new-car/invalid?orderNo={orderNo}")
    Result newCarInvalid(@Param("orderNo")String orderNo);

    /**
     * 新车删除钥匙库存
     * @description newCarDelete
     * @param keyBarCode
     * @return cn.seed.common.core.Result
     * @Exception
     * @author shuai.xu
     * @time 2019/6/3 10:51
    */
    @RequestLine("PUT /new-car/delete?keyBarCode={keyBarCode}")
    Result newCarDelete(@Param("keyBarCode")String keyBarCode);

    /**
     * 新车入库详情
     * @description selectNewCarDetail
     * @param orderNo
     * @return cn.seed.common.core.Result<cn.koala.key.stock.domain.vo.EnterStockDetailVO>
     * @Exception
     * @author shuai.xu
     * @time 2019/6/3 11:08
    */
    @RequestLine("GET /new-car?orderNo={orderNo}")
    Result<EnterStockDetailVO> selectNewCarDetail(@Param("orderNo")String orderNo);

    /**
     * 根据单号获取钥匙信息
     * @description selectNewCarKeyInfo
     * @param orderNo
     * @return cn.seed.common.core.Result<java.util.List<cn.koala.key.entity.KeyInfo>>
     * @Exception
     * @author shuai.xu
     * @time 2019/6/3 17:09
    */
    @RequestLine("GET /new-car/getKeyBarCode?orderNo={orderNo}")
    Result<List<KeyInfo>> selectNewCarKeyInfo(@Param("orderNo")String orderNo);

    @RequestLine("POST /borrow-orders/batch")
    Result<List<BorrowOrder>> importBorrowOrder(List<BorrowOrderDTO> orderList);

    @RequestLine("POST /file/upload?categoryId={categoryId}&referNo={referNo}&author={author}")
    Result<String> fileUpload(MultipartFile file, @Param("categoryId") Integer categoryId,
                              @Param("referNo") String referNo, @Param("author") String author);

}
